package de.fhd.pms;


import java.io.*;

import javax.servlet.*;
import javax.servlet.http.*;

public class ServPmsAdmin extends HttpServlet {
  private String greeting;
  private String pic_life;
  private String pic_series;

  
  public void init()
    throws ServletException
  {
    greeting = getInitParameter("greeting");
    pic_life = getInitParameter("pic_life");
    pic_series = getInitParameter("pic_series");
  }

  @Override
  public void doGet( HttpServletRequest request, HttpServletResponse response )
  throws ServletException, IOException
  {
     response.setContentType( "text/html" );
     PrintWriter out = response.getWriter();
     out.println( "<html>" );
     out.println("<title>" + greeting + "</title>");
     out.println("<h1>" + greeting + "</h1>");
     out.println( "<h3> Administrate a new record </h3>" );
	// new database record
     out.println("<TABLE ID='DataBaseRecord'>");
 	    out.println("<TR><TD colspan='2'>");
 	    out.println("<INPUT type=button id='a1' value=' New Face Record ' onClick='alert('Create Search Form');' ID='B1' NAME='NewRecord'>");
 	    out.println("<INPUT type=button id='a2' value=' Check Face Detection '  onClick='doAny();' ID='B2' NAME='CheckDetecktion'>");
 	    out.println("&nbsp;");
 	    out.println("<INPUT type=button id='a3' value=' Record Form  '  onClick='doAny();' ID='B3' NAME='DBForm'>");
 	    out.println("</TD></TR>");
 	out.println("</TABLE>");
 	//out.println( "<p><br />" );
     // picture output table 
     out.println( "<table border>" );
     out.println( "<tr>" );
	     out.println( "<td>");
	     out.println( "<img src="+ pic_life + " width='92' height='112' alt='life pic'/>"); 
	     out.println( "</td>");
	     out.println( "<td width='92'  > ->rec.pic's-> </td>");
	     out.println( "<td >");
	     out.println( "<img src="+ pic_series + " width='92' height='112'  alt='series pic'/>"); 
	     out.println( "</td>");
	     out.println( "<td >");
	     out.println( "<img src="+ pic_series + " width='92' height='112'  alt='series pic'/>"); 
	     out.println( "</td>");
	     out.println( "<td >");
	     out.println( "<img src="+ pic_series + " width='92' height='112'  alt='series pic'/>"); 
	     out.println( "</td>");
	     out.println( "<td >");
	     out.println( "<img src="+ pic_series + " width='92' height='112'  alt='series pic'/>"); 
	     out.println( "</td>");
	     out.println( "<td >");
	     out.println( "<img src="+ pic_series + " width='92' height='112'  alt='series pic'/>"); 
	     out.println( "</td>");
	     out.println( "<td >");
	     out.println( "<img src="+ pic_series + " width='92' height='112'  alt='series pic'/>"); 
	     out.println( "</td>");
	     out.println( "<td >");
	     out.println( "<img src="+ pic_series + " width='92' height='112'  alt='series pic'/>"); 
	     out.println( "</td>");
	     out.println( "<td >");
	     out.println( "<img src="+ pic_series + " width='92' height='112'  alt='series pic'/>"); 
	     out.println( "</td>");
	     out.println( "<td >");
	     out.println( "<img src="+ pic_series + " width='92' height='112'  alt='series pic'/>"); 
	     out.println( "</td>");
	     out.println( "<td >");
	     out.println( "<img src="+ pic_series + " width='92' height='112'  alt='series pic'/>"); 
	     out.println( "</td>");
	out.println( "</tr>" );
    out.println( "</table>" );
    out.println( "<p><br />" );
    
    //out.println( "<a href='visitors'>zur&uuml;ck</a>  " );
    
    // database table navigator functions
    out.println( "<h3> Manage database </h3>" );
	out.println("<TABLE ID='DataBase'>");
	    out.println("<TR><TD colspan='2'>");
	    out.println("<INPUT type=button id='b1' value=' Search ' onClick='alert('Create Search Form');' ID='Button1' NAME='Search'>");
	    out.println("&nbsp;");
	    out.println("<INPUT type=button id='b2' value=' << '  onClick='doAny();' ID='Button2' NAME='Begin'>");
	    out.println("<INPUT type=button id='b3' value=' <  '  onClick='doAny();' ID='Button3' NAME='Minus'>");
	    out.println("<INPUT type=button id='b4' value=' >  '  onClick='doAny();' ID='Button4' NAME='Plus'>");
	    out.println("<INPUT type=button id='b5' value=' >> '  onClick='doAny();' ID='Button5' NAME='End'>");
	    out.println("&nbsp;");
	    out.println("<INPUT type=button id='b6' value=' DB Info ' onClick='alert('Create DB Info');' ID='Button6' NAME='DBInfo'>");
	    out.println("&nbsp;");
	    out.println("<INPUT type=button id='b7' value=' Edit  ' onClick='doAny();' ID='Button7' NAME='Edit'>");
	    out.println("<INPUT type=button id='b8' value=' Clear  ' onClick='doAny();' ID='Button8' NAME='Clear'>");
	    out.println("&nbsp;");
	    out.println("<INPUT type=button id='b9' value=' Save '  onClick='doAny();' ID='Button9' NAME='Save'>");
	    out.println("</TD></TR>");
	out.println("</TABLE>");
   
    // todo: table to be updated dynamically
	 out.println( "<table border>" );
    out.println( "<tr>" );
	     out.println( "<td width='50'> Id</td>" );
	     out.println( "<td width='290'> name</td>" );
	     out.println( "<td width='200' > date</td>" );
	     out.println( "<td width='200'> info1</td>" );
	     out.println( "<td width='200'> info2</td>" );
	     out.println( "<td width='200'>  info3</td>" );
	 out.println( "</tr>" );
    out.println( "<tr>" );
	     out.println( "<td> 1 </td>" );
	     out.println( "<td> unknown </td>" );
	     out.println( "<td> 2</td>" );
	     out.println( "<td> 3</td>" );
	     out.println( "<td> 4</td>" );
	     out.println( "<td> 5</td>" );
	 out.println( "</tr>" );
    out.println( "<tr>" );
		 out.println( "<td> 2 </td>" );
	     out.println( "<td> unknown </td>" );
	     out.println( "<td> 2</td>" );
	     out.println( "<td> 3</td>" );
	     out.println( "<td> 4</td>" );
	     out.println( "<td> 5</td>" );
	 out.println( "</tr>" );
	    out.println( "<tr>" );
		 out.println( "<td> 3 </td>" );
	     out.println( "<td> unknown </td>" );
	     out.println( "<td> 2</td>" );
	     out.println( "<td> 3</td>" );
	     out.println( "<td> 4</td>" );
	     out.println( "<td> 5</td>" );
	 out.println( "</tr>" );
	 out.println( "</table>" );
	
	
	
	// javascript example code doAny();
    out.println("<SCRIPT language='javascript'>"); 
	out.println("var State = 0;");
	out.println(" function doAny(){" +
			    " alert('code area')"+
	             "};");
	out.println("</SCRIPT>");
	// also possible to use the <SCRIPT language="JScript">
    
    out.println( "</html>" );
    out.close();
  }
  
  public void destroy()
  {
    // nothing to do
  }
}
